﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ArtsShop.BusinessLogic;

namespace ArtsShop
{
    public partial class AddToCart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int productId;

            if ((!String.IsNullOrEmpty(rawId)) && (Int32.TryParse(rawId, out productId)))
            {
                ShoppingCart usersShoppingCart = new ShoppingCart();
                String cartId = usersShoppingCart.GetShoppingCartId();
                usersShoppingCart.AddItem(cartId, productId, 1);
            }
            //default action
            Response.Redirect("MyShoppingCart.aspx");
        }
    }
}
